/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期:  2021年5月23日
 */
package com.massyframework.beanskin.framework;

import com.massyframework.beanskin.ModuleRepository;
import com.massyframework.beanskin.StartStopAbility;
import com.massyframework.beanskin.assembly.Assembly;

/**
 * 运行框架
 * @author huangkh
 *
 */
public interface Framework  extends ModuleRepository, StartStopAbility{
	
	// ========================================================================
	//    运行环境
	// ========================================================================
	/* 运行环境 */
	static final String RUN_ENVIRONMENT                    = "environment";   
	/* 运行环境取值： J2EE  */
	static final String RUN_ENVIRONMENT_J2EE               = "j2ee";
	/* 运行环境取值： J2SE */
	static final String RUN_ENVIRONMENT_J2SE               = "j2se";
	
	// ========================================================================
	//    调试模式
	// ========================================================================
	/* 调试模式 */
    static final String DEBUG_MODEL                        = "debug.model";
    
	// ========================================================================
	//    本地存储
	// ========================================================================
	/* 本地存储目录 */
	static final String STORAGE                            = "framework.storage";
	/* 本地存储目录--片段 */
	static final String STORAGE_FRAGMENT                   = "framework.storage.fragment";
	/* 本地存储目录--前端 */
	static final String STORAGE_FRONTEND                   = "framework.storage.frontend";
	
	
	/* 本地存储清理策略 */
    static final String STORAGE_CLEAN                      = "framework.storage.clean";
    /* 本地存储清理策略取值： 不清理 */
    static final String STORGE_CLEAN_NONE                  = "none";
    /* 本地存储清理策略取值： 启动删除本地存储的所有文件(含目录) */
    static final String STORGE_CLEAN_ONFIRSTCLEAN          = "onFirstInit";
    
    /* 许可中心 */
    static final String LICENSE_CENTER                     = "license.center";
     
    /**
     * 添加事件监听器 
     * @param listener {@link FrameworkListener},事件监听器
     */
    void addListener(FrameworkListener listener);
    
    /**
     * 初始化
     * <p>
     * 初始化期间将加载类库、插件两种模块。
     * @throws {@link ExceptionGroup},启动期间发生的所有例外
     */
    void init();
    
    /**
     * 是否处于运行中
     * <p>
     * 当执行{@link #start()}方法后，返回{@code true};
     * 当执行{@link #stop()}方法后，返回{@code false}
     * @return {@link boolean}
     */
    boolean isRunning();
    
    /**
     * 启动装配件
     * <p>
     * 如果未初始化，会先调用{@link #init()}进行初始化
     * @param assembly {@link Assembly}
     * @throws Exception 
     */
    void start(Assembly assembly) throws Exception;
            
    /**
     * 停止装配件
     * @param assembly {@link Assembly}
     * @throws Exception 
     */
    void stop(Assembly assembly) throws Exception;
    
    /**
     * 释放
     */
    void destory();
        
    /**
     * 移除事件监听器
     * @param listener {@link FrameworkListener},事件监听器
     */
    void removeListener(FrameworkListener listener);
}
